public class TakeAttendance {
    public int takeAttendance(int[] records) {
        int n = records.length;
        int left = 0, right = n - 1;
        while(left < right){
            int mid = left + ((right - left) >> 1);
            if(records[mid] == mid) {
                left = mid + 1;
            }else {
                right = mid;
            }
        }
        // 边界情况处理
        if(left == right && records[left] == left) {
            return records[left] + 1;
        }

        return left;
    }
}
